﻿using CommonServiceLocator;
using TimerJobServerManager.Common;
using TimerJobServerManager.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TimerJobServerManager
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void txtLog_TextChanged(object sender, TextChangedEventArgs e)
        {
            System.Windows.Controls.TextBox textBox = (System.Windows.Controls.TextBox)(sender);
            textBox.ScrollToEnd();
        }

        private void WindowBase_Closed(object sender, EventArgs e)
        {
            //保存服务配置
            ServerManagerConfig.Save();
            //如果设置退出时停止服务则停止服务
            if (ServerManagerConfig.Default.ExitCloseServer)
            {
                MainViewModel main = ServiceLocator.Current.GetInstance<MainViewModel>();
                main.ServiceStopCommand.Execute(null); //执行停止服务命令
            }
        }
    }
}
